import http.client

class SenderBase:
    def __init__(self, url, port):
        self.URL = url
        self.PORT = port

    def send(self, url, payload):
        try:
            conn = http.client.HTTPConnection(self.URL, self.PORT)
            headers = {'Content-Type': 'application/json'}
            conn.request("POST", url, payload, headers)
            return conn.getresponse()
        except:
            raise Exception("Failed to send request to the server")